#ifndef SPEECHMANAGER_H
#define SPEECHMANAGER_H

#include <glib.h>
#include <gio/gio.h>

#include <coreai/speech/recognizer.h>
#include <QObject>
#include <QDebug>

class SpeechManager : public QObject
{
    Q_OBJECT
public:
    bool isListening;
    struct SpeechRecognitionData {
        QString text;
//        int speakerId;
        bool isFinal;
        bool error=false;
    };
    SpeechRecognitionData recognitionData;


public:
    explicit SpeechManager(QObject *parent = nullptr);
    ~SpeechManager();

    bool initialize();
    void startListening();
    void stopListening();
    void recognizeOnce();
    void setAudioConfig(const AudioConfig &config);
    void setModelConfig(const SpeechModelConfig &config);

signals:
    // 识别结果信号
    void recognitionResult(bool isFinal);

private:
    static void speechCallback(SpeechRecognitionResult *result, void *user_data);

    SpeechRecognitionSession *speechSession;

};

#endif // SPEECHMANAGER_H
